<?php
	require_once('../session.inc');
	if ($_SESSION['IsLogin'] == 0 || $_SESSION['Authentication'] != 2)
	{
		header("Location:index.php");
	}
	
	if (isset($_REQUEST['maLoaiSP']) && isset($_REQUEST['type']) && isset($_REQUEST['t']) &&
		is_numeric($_REQUEST['type']) && is_numeric($_REQUEST['t']))
	{		
		require_once('../class/SanPhamDAO.php');
		require_once('../class/LoaiSanPhamDAO.php');
		$token = strtok($_REQUEST['maLoaiSP'], ",");
		$dsSanPham = array();
		$strSanPham = "";
		while ($token != false)
		{
			$maLoaiSP = $token;
			if (strlen($maLoaiSP) > 0 && is_numeric($maLoaiSP) )
			{
				$dsSPtemp = SanPhamDAO::LayDanhSachSanPhamTheoLoaiSanPham($maLoaiSP, 0);
				if (count($dsSPtemp) > 0)
				{
					$loaiSPtemp = LoaiSanPhamDAO::LayLoaiSanPhamTheoMaLoai($maLoaiSP);
					$strSanPham .= '<div class="text_line">Loại sản phẩm: <b>'.$loaiSPtemp->TenLoaiSP.' </b></div>';
					foreach($dsSPtemp as $spTemp)
					{					
						array_push($dsSanPham, $spTemp);
						$func = "funcChonSanPham('".$spTemp->Ma."')";
						$strSanPham .= '<img class="thumbnail" name="imgSP" src="'.$spTemp->HinhAnh.'" width="80" height="80" title="'.$spTemp->TenSanPham.'" id="imgSP_'.$spTemp->Ma.'" onclick="'.$func.'" value="'.$spTemp->Ma.'" >';
						
					}
				}
			}
			
			$token = strtok(",");			
		}	
		// xuất ra màn hình
		echo $strSanPham;
	}

?>